/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package gmovil_jpa.entidades;

import java.io.Serializable;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;

/**
 *
 * @author castlerock
 */
@Entity
@Table(name = "detalle_orden_compra")
@NamedQueries({
    @NamedQuery(name = "DetalleOrdenCompra.findAll", query = "SELECT d FROM DetalleOrdenCompra d"),
    @NamedQuery(name = "DetalleOrdenCompra.findByIdDetalleOrdenCompra", query = "SELECT d FROM DetalleOrdenCompra d WHERE d.idDetalleOrdenCompra = :idDetalleOrdenCompra"),
    @NamedQuery(name = "DetalleOrdenCompra.findByCantidad", query = "SELECT d FROM DetalleOrdenCompra d WHERE d.cantidad = :cantidad"),
    @NamedQuery(name = "DetalleOrdenCompra.findByPrecio", query = "SELECT d FROM DetalleOrdenCompra d WHERE d.precio = :precio"),
    @NamedQuery(name = "DetalleOrdenCompra.findByIva", query = "SELECT d FROM DetalleOrdenCompra d WHERE d.iva = :iva"),
    @NamedQuery(name = "DetalleOrdenCompra.findByDescuento", query = "SELECT d FROM DetalleOrdenCompra d WHERE d.descuento = :descuento")})
public class DetalleOrdenCompra implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "id_detalle_orden_compra")
    private Integer idDetalleOrdenCompra;
    @Basic(optional = false)
    @Column(name = "cantidad")
    private int cantidad;
    @Basic(optional = false)
    @Column(name = "precio")
    private double precio;
    @Basic(optional = false)
    @Column(name = "iva")
    private double iva;
    @Basic(optional = false)
    @Column(name = "descuento")
    private double descuento;
    @JoinColumn(name = "fid_modelo", referencedColumnName = "id_modelo")
    @ManyToOne(optional = false)
    private Modelo modelo;
    @JoinColumn(name = "fid_orden_compra", referencedColumnName = "id_orden_compra")
    @ManyToOne(optional = false)
    private OrdenCompra ordenCompra;

    public DetalleOrdenCompra() {
    }

    public DetalleOrdenCompra(Integer idDetalleOrdenCompra) {
        this.idDetalleOrdenCompra = idDetalleOrdenCompra;
    }

    public DetalleOrdenCompra(Integer idDetalleOrdenCompra, int cantidad, double precio, double iva, double descuento) {
        this.idDetalleOrdenCompra = idDetalleOrdenCompra;
        this.cantidad = cantidad;
        this.precio = precio;
        this.iva = iva;
        this.descuento = descuento;
    }

    public Integer getIdDetalleOrdenCompra() {
        return idDetalleOrdenCompra;
    }

    public void setIdDetalleOrdenCompra(Integer idDetalleOrdenCompra) {
        this.idDetalleOrdenCompra = idDetalleOrdenCompra;
    }

    public int getCantidad() {
        return cantidad;
    }

    public void setCantidad(int cantidad) {
        this.cantidad = cantidad;
    }

    public double getPrecio() {
        return precio;
    }

    public void setPrecio(double precio) {
        this.precio = precio;
    }

    public double getIva() {
        return iva;
    }

    public void setIva(double iva) {
        this.iva = iva;
    }

    public double getDescuento() {
        return descuento;
    }

    public void setDescuento(double descuento) {
        this.descuento = descuento;
    }

    public Modelo getModelo() {
        return modelo;
    }

    public void setModelo(Modelo modelo) {
        this.modelo = modelo;
    }

    public OrdenCompra getOrdenCompra() {
        return ordenCompra;
    }

    public void setOrdenCompra(OrdenCompra ordenCompra) {
        this.ordenCompra = ordenCompra;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idDetalleOrdenCompra != null ? idDetalleOrdenCompra.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof DetalleOrdenCompra)) {
            return false;
        }
        DetalleOrdenCompra other = (DetalleOrdenCompra) object;
        if ((this.idDetalleOrdenCompra == null && other.idDetalleOrdenCompra != null) || (this.idDetalleOrdenCompra != null && !this.idDetalleOrdenCompra.equals(other.idDetalleOrdenCompra))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "gmovil_jpa.entidades.DetalleOrdenCompra[idDetalleOrdenCompra=" + idDetalleOrdenCompra + "]";
    }

}
